package com.xc.controller.agent;

import com.xc.common.ServerResponse;
import com.xc.service.IUserPositionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author mipha
 * @version 1.0
 * @date 2019/2/24 8:50 PM
 */
@Controller
@RequestMapping("/agent/position/")
@Slf4j
public class AgentPositionController {

    @Autowired
    IUserPositionService iUserPositionService;

    /**
     *  查询代理下用户持仓列表
     * @param request
     * @param pageNum
     * @param pageSize
     * @param positionType
     * @param state
     * @param userId
     * @param agentId
     * @param beginTime
     * @param endTime
     * @return
     */
    @RequestMapping("list.do")
    @ResponseBody
    public ServerResponse list(HttpServletRequest request
                               ,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
                               ,@RequestParam(value = "pageSize", defaultValue = "10") int pageSize
                               ,@RequestParam(value = "positionType", required = false) Integer positionType
                               ,@RequestParam(value = "state", required = false) Integer state
                               ,@RequestParam(value = "userId", required = false) Integer userId
                               ,@RequestParam(value = "agentId", required = false) Integer agentId
                               ,@RequestParam(value = "positionSn", required = false) String positionSn
                                ,@RequestParam(value = "beginTime", required = false) String beginTime
                                ,@RequestParam(value = "endTime", required = false) String endTime
    ){
        return iUserPositionService.listByAgent(positionType ,state ,userId ,agentId
                ,positionSn ,beginTime ,endTime ,request ,pageNum ,pageSize);
    }




}
